home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 3.2 KB | 168 lines | [TEXT/MSET] |
- \ 28Oct94 dbh updated to 2.5 syntax
- \ 06Nov94 dbh reverted to obj_array, which is fixed with 2.5
-
- (*
- A radioGroup is an array of radio buttons, we normally would neveer use
- a radio button except as part of a group. The buttons are vertically
- aligned and behave as expected. We optionally use init: to set the initial
- position and which button will be the first to be set. We use get: to
- inspect which button is now on, get: returns the zero-based indice of
- the currently selected button. A radioGroup is a selection object.
-
- *)
-
- :class radioBut super{ pushButton }
- int index \ each button must know its index number, 0,1,2,3,etc.
- DICADDR theGroup \ each button must know the owning group because of the
- \ way exec: is invoked, we need to communicate back to the owning group
-
- :m classinit:
- classinit: super
- konst radioButProc put: procID
- " RadioButton" put: cTitle
- ;m
-
- :m init: ( radioGroup idx -- )
- put: index
- put: theGroup ;m
-
- :m exec: ( part# -- )
- IF
- get: index put: [ get: theGroup ]
- get: action execute
- THEN ;m
-
- ;class
-
-
- :class radioGroup super{ radioBut obj_array }
- int top
- int left
- int yspacing
- int nowOn \ will default to zero
-
- :m init: ( x y firston -- )
- dup limit: super 1 - > abort" firstOn in radioGroup is out of range"
- put: nowOn
- put: top
- put: left
- ;m
-
- private
-
- :m othersOff: { idx -- }
- limit: self 0 \ indexed-obj method
- ?DO
- i idx = \ in case we hit the button currently on, avoid flicker
- NIF
- i select: super> obj_array
- 0 put: super> radioBut
- THEN
- LOOP ;m
-
-
- public
-
- :m classinit:
- 0 put: nowOn
- 20 put: top
- 20 put: left
- 17 put: yspacing
- \ selfinit: super \ should normally call this for obj_array's
- \ now we can set each control's index to the proper unique value
- limit: self 0 \ indexed-obj method
- ?DO
- I select: super> obj_array
- self I init: super> radioBut
- LOOP
- ;m
-
- :m new: { wptr -- }
-
- limit: self 0 \ indexed-obj method
- ?DO
- i select: super> obj_array
-
- get: left ( x)
- get: top
- i get: yspacing * + ( y) MoveTo: super> radioBut
-
- wptr new: super> radioBut
- LOOP
-
- \ now turn the desired button "on"
- get: nowOn select: super
- 1 put: super
- ;m
-
- :m draw:
- limit: self 0 \ indexed-obj method
- ?DO
- I select: super> obj_array
- draw: super> radioBut
- LOOP
- ;m
-
- :m release:
- limit: self 0 \ indexed-obj method
- ?DO
- I select: super> obj_array
- release: super> radioBut
- LOOP
- ;m
-
- :m activate:
- limit: self 0 \ indexed-obj method
- ?DO
- I select: super> obj_array
- activate: super> radioBut
- LOOP
- ;m
-
- :m deactivate:
- limit: self 0 \ indexed-obj method
- ?DO
- I select: super> obj_array
- deactivate: super> radioBut
- LOOP
- ;m
-
- :m hit?: { \ flg -- b }
- false -> flg
- limit: self 0 \ indexed-obj method
- ?DO
- I select: super> obj_array
- hit?: super> radioBut
- IF I put: nowOn true -> flg leave THEN \ we also have f on the stack if true
- LOOP flg ;m
-
- :m get: ( -- idx ) \ returns which button is on
- get: nowOn ;m
-
- :m put: { idx -- } \ manually select a button
- idx othersOff: self
- idx select: super
- idx put: nowOn
- 1 put: super ;m
-
- :m SetTitle: ( addr len idx -- )
- select: super
- setTitle: super ;m
-
- :m action: ( cfa idx -- )
- select: super
- action: super ;m
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- selwindow w
- test: w
-
- 4 radioGroup r
- r add: w
-
-